package com.fuershiye.woman.monitor.constants;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fuershiye.woman.monitor.beans.IdName;
import com.google.common.collect.Lists;

/**
 * 目前只考虑，3种无目标值：YEAR_UP(1, "逐年上升"),YEAR_DOWN(2, "逐年下降")，EXSIT_VALUE(3, "存在一定比例"),
 * 目前只考虑，5种有目标值：AIM_UP(4, "大于目标值"),AIM_EQUAL(5, "等于目标值"),AIM_DOWN(6, "小于目标值"),
 * AIM_EQUAL_UP(7, "大于等于目标值"),AIM_EQUAL_DOWN(8, "小于等于目标值"),
 *
 * */
public enum Rules {

    //默认值，未少报
	IS_NULL(0, ""),
	YEAR_UP(1, "逐年上升"),
	YEAR_DOWN(2, "逐年下降"),
	EXSIT_VALUE(3, "存在一定比例"),
	
	AIM_UP(4, "大于目标值"),
	AIM_EQUAL(5, "等于目标值"),
	AIM_DOWN(6, "小于目标值"),
	AIM_EQUAL_UP(7, "大于等于目标值"),
	AIM_EQUAL_DOWN(8, "小于等于目标值"),
//	AIM_BETWEEN(9, "目标值在区间内"),
	
	//	(今年-去年)/去年  比较 目标值
//	RATE_UP(10, "增长率大于目标值"),
//	RATE_EQUAL(11, "增长率等于目标值"),
//	RATE_DOWN(12, "增长率小于目标值"),
//	RATE_EQUAL_UP(13, "增长率大于等于目标值"),
//	RATE_EQUAL_DOWN(14, "增长率小于等于目标值"),
//	RATE_BETWEEN_UP(15, "增长率在区间内上升"),
//	RATE_BETWEEN_DOWN(16, "增长率在区间内下降"),
	
//	PARENT_UP(17, "实际值大于父级指标"),
//	PARENT_EQUAL(18, "实际值等于父级指标"),
//	PARENT_DOWN(19, "实际值小于父级指标"),
//	PARENT_EQUAL_UP(20, "实际值大于等于父级指标"),
//	PARENT_EQUAL_DOWN(21, "实际值小于等于父级指标"),
//	PARENT_BETWEEN_UP(22, "实际值大于父级指标在区间内"),
//	PARENT_BETWEEN_DOWN(23, "实际值小于父级指标在区间内"),

//	PARENT_RATE_UP(24, "占父级指标百分比大于目标值"),
//	PARENT_RATE_EQUAL(25, "占父级指标百分比等于目标值"),
//	PARENT_RATE_DOWN(26, "占父级指标百分比小于目标值"),
//	PARENT_RATE_EQUAL_UP(27, "占父指标百分比大于等于目标值"),
//	PARENT_RATE_EQUAL_DOWN(28, "占父指标百分比小于等于目标值"),
//	PARENT_RATE_BETWEEN_UP(29, "占父指标百分比大于目标值在某区间内"),
//	PARENT_RATE_BETWEEN_DOWN(30, "占父指标百分比小于目标值在某区间内"),
	
	;

    private final Integer code;
    private final String name;

	private static final Map<Integer,Rules> lookupByCode=new HashMap<Integer, Rules>();
	private static final List<IdName> allIdName = Lists.newArrayList();

    static {
        for(final Rules r: EnumSet.allOf(Rules.class)){
            lookupByCode.put(r.getCode(), r);
        }
    }
    
    static {
    	for(final Rules r: EnumSet.allOf(Rules.class)){
    		allIdName.add(new IdName(r.getCode(), r.getName()));
    	}
    }
    
    static {
    	for(final Rules r: EnumSet.allOf(Rules.class)){
    		lookupByCode.put(r.getCode(), r);
    	}
    }

    Rules(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static Rules getByCode(int code){
        return lookupByCode.get(code);
    }
    
    public static String getNameByCode(int code){
    	if(lookupByCode.containsKey(code)){
        	return lookupByCode.get(code).name;
    	}
    	return "";
    }
    
    public static Map<Integer,Rules> getAll(){
    	return lookupByCode;
    }
    
    public static List<IdName> getAllIdName(){
    	return allIdName;
    }
    
}
